#include <iostream>
using namespace std;

int n;
int a, b;
int num[7];

bool IsPrime(int x) {
  if (x % 2 == 0) {
    return false;
  }
  for (int i = 3; i <= x / i; i += 2) {
    if (x % i == 0) {
      return false;
    }
  }
  return true;
}

void DFS(int now) {
  if (now > n - now) {
    int x = 0;
    for (int i = 0; i <= n; i++) {
      x = x * 10 + num[i];
    }
    if (a <= x && x <= b && IsPrime(x)) {
      cout << x << "\n";
    }
    return;
  }
  if (now == 0) {
    for (num[now] = 1; num[now] < 10; num[now] += 2) {
      num[n - now] = num[now];
      DFS(now + 1);
    }
  } else {
    for (num[now] = 0; num[now] < 10; num[now]++) {
      num[n - now] = num[now];
      DFS(now + 1);
    }
  }
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

  cin >> a >> b;
  for (n = 0; n < 7; n++) {
    DFS(0);
  }
  return 0;
}